package com.example.dynamicdatasource.controller;


import com.example.dynamicdatasource.entity.User;
import com.example.dynamicdatasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lx
 * @since 2021-03-02
 */
@RestController
@RequestMapping("api/users")
public class UserController {

    @Autowired
    private UserService teacherService;

    @GetMapping
    public ResponseEntity<List<User>> listTeacher(){
        teacherService.save(new User("lx",31));
        List<User> teacherList = teacherService.list();
        return ResponseEntity.ok(teacherList);
    }

}
